import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
import Full from '@/containers/Full';
import SignOn from '@/containers/SignOn';
import Register from '@/containers/Register';
import Forget from '@/containers/Forget';
import ResetPwd from '@/containers/ResetPwd';

// Views - Pages
import Page404 from '@/views/errorPages/Page404'
import Page500 from '@/views/errorPages/Page500'
import { mapGetters } from 'vuex'

/* login */
Vue.use(Router);

export const constantRouterMap = [
    {path: '/pages',redirect: '/pages/p404', name: 'Pages',
          component: {
            render (c) { return c('router-view') }
              // Full,
          },
          children: [{path: '404',  name: 'Page404', component: _import('errorPages/Page404') },
                     {path: '500',name: 'Page500',component: _import('errorPages/Page404')},
                    ]
    }
];

export default new Router({
  mode: 'hash',
  linkActiveClass: 'open',
  // scrollBehavior: () => ({ y: 0 }),
  scrollBehavior (to, from, savedPosition) {
    if (to.hash) {
      return {
        selector: to.hash
      }
    }
  },
  routes: constantRouterMap,
});

export var asyncRouterMap = [
    {
        path: '/',
        name: '首页',
        component: Full,
        hidden:false,
        children: [
            {path: '/home',name: '主页',icon:'speedometer',component: _import('home')},
            {path: '/introduction',name: '使用介绍',icon:'thumbsup',component: _import('Introduction')},
            { path: '/demo', name: '模板', icon: 'thumbsup', component: _import('demo') }
        ]
    },
    {
        path: '/login',
        name: '登录',
        component: SignOn,
        hidden:false
    },
    {
        path: '/reg',
        name: '注册账号',
        component: Register,
        hidden:false
    },
    {
        path: '/forget',
        name: '找回密码',
        component: Forget,
        hidden:false
    },
    {
        path: '/repwd',
        name: '重置密码',
        component: ResetPwd,
        hidden:false
    },
    { path: '*', redirect: '/pages/404', hidden: true }

];
